/**
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.messages.client.MsgLeaderBrdReply;
import edu.wpi.cs509.representation.UserName;



/**
 * This class implements the get-leaderboard message, based
 * on username/count.
 * @author sparadis
 *
 */
public class MsgGetLeaderBrdUser extends MsgServerContext {

	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * rank and count to filter leaderboard by
	 */
	protected UserName username;
	protected int count;
	
	/**
	 * Constructor.
	 * @param rank - rank used by leaderboard filtering
	 * @param count - count used by leaderboard filtering
	 */
	public MsgGetLeaderBrdUser(String username, int count) {
		this.username = new UserName(username);
		this.count = count;
	}

	/**
	 * Get the leaderbrd.
	 * @return MsgBc - the reply msg with the leadedbrd contents
	 */
	public MsgBc doExecuteAndGetReply() {
		//Get the leaderboard by username/count, return it in the reply msg.
		//TODO: need to somehow get the rank of the first user returned...
		return (new MsgLeaderBrdReply(
				getServer().getLeaderBoard(username, count, this.getConnection()), 0));
	}
}
